
//
//  ViewForCollectionHeaderForSearch.m
//  ProjectA
//
//  Created by dllo on 16/2/29.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "ViewForCollectionHeaderForSearch.h"
#import "AppMacro.h"
@interface ViewForCollectionHeaderForSearch ()

@end

@implementation ViewForCollectionHeaderForSearch
- (void)dealloc {
    [_button release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    [super initWithFrame:frame];
    if (self) {
        
        self.label = [[UILabel alloc] init];
        [self addSubview:self.label];
        [_label release];
        
        self.button = [UIButton buttonWithType:UIButtonTypeSystem];
        [self addSubview:self.button];
        self.button.hidden = YES;
        
    }
    return self;
}

- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super preferredLayoutAttributesFittingAttributes:layoutAttributes];
    self.label.frame = self.bounds;
    self.label.textAlignment = 1;
    [UIView setColorWithLabelText:self.label nightColor:L_COLOR_WHITE dayColor:L_COLOR_BLACK];
    
    self.button.frame = CGRectMake(self.label.center.x + self.label.frame.size.width / 10.f + 10, self.label.center.y - self.label.frame.size.height / 3.75f, 25, 25);
    
    
    if (ISNIGHT) {
        [self.button setBackgroundImage:[UIImage imageNamed:@"iconfont-qingchu(baise)"] forState:UIControlStateNormal];
    } else {
        [self.button setBackgroundImage:[UIImage imageNamed:@"iconfont-qingchu(heise)"] forState:UIControlStateNormal];
    }
    
    return layoutAttributes;
    
}

@end
